/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.imgs;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * <p>Project: javaseapp - Imt6
 * <p>Powered by webrx On 2021-08-13 17:37:24
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Imt6 {
    public static void main(String[] args) {

        try {
            //读取logo.png
            BufferedImage logo = ImageIO.read(new File("images/logo.png"));
            int ww = logo.getWidth();
            int hh = logo.getHeight();

            BufferedImage logo2 = ImageIO.read(new File("images/logo2.png"));
            int www = logo2.getWidth();
            int hhh = logo2.getHeight();


            BufferedImage dst = ImageIO.read(new File("images/s4.jpg"));
            int w = dst.getWidth();
            int h = dst.getHeight();

            var g = dst.createGraphics();
            int x = (w - ww) / 2;
            int y = (h - hh) / 2;
            //设置画图的透明度 .5f透明一半
            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, .5f));
            g.drawImage(logo2, w - www - 20, h - hhh - 20, null);
            g.drawImage(logo, x, y, null);
            g.dispose();

            ImageIO.write(dst, "jpg", new File("images/s4_logo.jpg"));

            Runtime run = Runtime.getRuntime();
            run.exec("cmd /k start images/s4_logo.jpg");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
